package com.vietnam.power.persitence;

import java.io.Serializable;

import javax.persistence.*;

import org.hibernate.annotations.Cascade;

import com.vietnam.power.domain.Root;
import com.vietnam.power.domain.UpdatableRoot;

import java.util.Date;
import java.util.List;

/**
 * The persistent class for the user_info database table.
 * 
 */
@Entity
@Table(name = "user_info")
public class UserInfo implements Serializable, Root, UpdatableRoot {
	private static final long serialVersionUID = 1L;
	private int id;
	private boolean accountNonExpired;
	private boolean accountNonLocked;
	private String country;
	private String countryCode;
	private Date createdDate;
	private String email;
	private boolean enabled;
	private String firstName;
	private String gender;
	private String lastName;
	private short loginAttempts;
	private String password;
	private boolean passwordNonExpired;
	private String phone;
	private String timezone;
	private Date updatedDate;
	private String userName;
	private List<Article> articles;
	private List<PasswordHistory> passwordHistories;
	private List<Product> products;
	private List<ProductGroup> productGroups;
	private List<UserRole> userRoles;
	private FileUpload avatarId;

	public UserInfo() {
	}

	public UserInfo(int id) {
		this.id = id;
	}

	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	public int getId() {
		return this.id;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "avatar_id")
	public FileUpload getAvatarId() {
		return avatarId;
	}

	public void setAvatarId(FileUpload avatarId) {
		this.avatarId = avatarId;
	}

	public void setId(int id) {
		this.id = id;
	}

	@Column(name = "account_non_expired")
	public boolean getAccountNonExpired() {
		return this.accountNonExpired;
	}

	public void setAccountNonExpired(boolean accountNonExpired) {
		this.accountNonExpired = accountNonExpired;
	}

	@Column(name = "account_non_locked")
	public boolean getAccountNonLocked() {
		return this.accountNonLocked;
	}

	public void setAccountNonLocked(boolean accountNonLocked) {
		this.accountNonLocked = accountNonLocked;
	}

	public String getCountry() {
		return this.country;
	}

	public void setCountry(String country) {
		this.country = country;
	}

	@Column(name = "country_code")
	public String getCountryCode() {
		return this.countryCode;
	}

	public void setCountryCode(String countryCode) {
		this.countryCode = countryCode;
	}

	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "created_date")
	public Date getCreatedDate() {
		return this.createdDate;
	}

	public void setCreatedDate(Date createdDate) {
		this.createdDate = createdDate;
	}

	public String getEmail() {
		return this.email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	public boolean getEnabled() {
		return this.enabled;
	}

	public void setEnabled(boolean enabled) {
		this.enabled = enabled;
	}

	@Column(name = "first_name")
	public String getFirstName() {
		return this.firstName;
	}

	public void setFirstName(String firstName) {
		this.firstName = firstName;
	}

	public String getGender() {
		return this.gender;
	}

	public void setGender(String gender) {
		this.gender = gender;
	}

	@Column(name = "last_name")
	public String getLastName() {
		return this.lastName;
	}

	public void setLastName(String lastName) {
		this.lastName = lastName;
	}

	@Column(name = "login_attempts")
	public short getLoginAttempts() {
		return this.loginAttempts;
	}

	public void setLoginAttempts(short loginAttempts) {
		this.loginAttempts = loginAttempts;
	}

	public String getPassword() {
		return this.password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	@Column(name = "password_non_expired")
	public boolean getPasswordNonExpired() {
		return this.passwordNonExpired;
	}

	public void setPasswordNonExpired(boolean passwordNonExpired) {
		this.passwordNonExpired = passwordNonExpired;
	}

	public String getPhone() {
		return this.phone;
	}

	public void setPhone(String phone) {
		this.phone = phone;
	}

	public String getTimezone() {
		return this.timezone;
	}

	public void setTimezone(String timezone) {
		this.timezone = timezone;
	}

	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "updated_date")
	public Date getUpdatedDate() {
		return this.updatedDate;
	}

	public void setUpdatedDate(Date updatedDate) {
		this.updatedDate = updatedDate;
	}

	@Column(name = "user_name")
	public String getUserName() {
		return this.userName;
	}

	public void setUserName(String userName) {
		this.userName = userName;
	}

	// bi-directional many-to-one association to Article
	@OneToMany(mappedBy = "userInfo")
	public List<Article> getArticles() {
		return this.articles;
	}

	public void setArticles(List<Article> articles) {
		this.articles = articles;
	}

	public Article addArticle(Article article) {
		getArticles().add(article);
		article.setUserInfo(this);

		return article;
	}

	public Article removeArticle(Article article) {
		getArticles().remove(article);
		article.setUserInfo(null);

		return article;
	}

	// bi-directional many-to-one association to PasswordHistory
	@OneToMany(mappedBy = "userInfo", cascade={CascadeType.MERGE})
	public List<PasswordHistory> getPasswordHistories() {
		return this.passwordHistories;
	}

	public void setPasswordHistories(List<PasswordHistory> passwordHistories) {
		this.passwordHistories = passwordHistories;
	}

	public PasswordHistory addPasswordHistory(PasswordHistory passwordHistory) {
		getPasswordHistories().add(passwordHistory);
		passwordHistory.setUserInfo(this);

		return passwordHistory;
	}

	public PasswordHistory removePasswordHistory(PasswordHistory passwordHistory) {
		getPasswordHistories().remove(passwordHistory);
		passwordHistory.setUserInfo(null);

		return passwordHistory;
	}

	// bi-directional many-to-one association to Product
	@OneToMany(mappedBy = "userInfo")
	public List<Product> getProducts() {
		return this.products;
	}

	public void setProducts(List<Product> products) {
		this.products = products;
	}

	public Product addProduct(Product product) {
		getProducts().add(product);
		product.setUserInfo(this);

		return product;
	}

	public Product removeProduct(Product product) {
		getProducts().remove(product);
		product.setUserInfo(null);

		return product;
	}

	// bi-directional many-to-one association to ProductGroup
	@OneToMany(mappedBy = "userInfo")
	public List<ProductGroup> getProductGroups() {
		return this.productGroups;
	}

	public void setProductGroups(List<ProductGroup> productGroups) {
		this.productGroups = productGroups;
	}

	public ProductGroup addProductGroup(ProductGroup productGroup) {
		getProductGroups().add(productGroup);
		productGroup.setUserInfo(this);

		return productGroup;
	}

	public ProductGroup removeProductGroup(ProductGroup productGroup) {
		getProductGroups().remove(productGroup);
		productGroup.setUserInfo(null);

		return productGroup;
	}

	// bi-directional many-to-one association to UserRole
	@OneToMany(mappedBy = "userInfo", cascade=CascadeType.ALL, orphanRemoval=true)
	public List<UserRole> getUserRoles() {
		return this.userRoles;
	}

	public void setUserRoles(List<UserRole> userRoles) {
		this.userRoles = userRoles;
	}

	public UserRole addUserRole(UserRole userRole) {
		getUserRoles().add(userRole);
		userRole.setUserInfo(this);

		return userRole;
	}

	public UserRole removeUserRole(UserRole userRole) {
		getUserRoles().remove(userRole);
		userRole.setUserInfo(null);

		return userRole;
	}

}